<template>
  <div class="article-list">
    <div
      class="article-item"
      v-for="item in list"
      :key="item.articleId"
      @click="goToDetail(item.articleId)"
    >
      <div class="text">
        <h3 class="title">{{ item.title }}</h3>
        <div class="meta">
          <span class="author">{{ item.authorName }}</span>
          <span class="comments">🗨️ {{ item.commentCount }}</span>
        </div>
      </div>
      <div class="cover">
        <img :src="item.cover" alt="封面图" />
      </div>
    </div>
  </div>
  <div v-if="!list.length" class="empty-container">
    <div class="empty-text">这里空空如也，快去发布第一篇文章吧！</div>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
defineProps({ list: Array })
const router = useRouter()
const goToDetail = (id) => router.push(`/home/article/${id}`)
</script>

<style scoped>
.article-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px;
}
.article-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  padding: 16px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  cursor: pointer;
}
.article-item:hover {
  background-color: #f0f9ff;
}
.text {
  flex: 1;
  margin-right: 12px;
}
.title {
  font-size: 16px;
  font-weight: bold;
  margin: 0;
}
.meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}
.cover img {
  width: 100px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
}

/* 空状态容器 */
.empty-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  padding: 40px 20px;
  background: linear-gradient(145deg, #f8f9fa 0%, #f1f3f5 100%);
  border-radius: 16px;
  margin-top: 20px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.03);
}
.empty-content {
  text-align: center;
  max-width: 480px;
}

/* 文字提示 */
.empty-text {
  font-size: 18px;
  color: #666;
  margin-bottom: 32px;
  line-height: 1.6;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}
</style>
